<template>
  <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-position="top">
    <el-form-item label="用户名" prop="username">
      <el-input v-model="ruleForm.username" placeholder="请输入用户名"></el-input>
    </el-form-item>
    <el-form-item label="密码" prop="password">
      <el-input v-model="ruleForm.password" placeholder="请输入密码"></el-input>
    </el-form-item>
    <el-form-item label="验证码" prop="code" style="margin-bottom: 10px;">
      <div class="codeBox flex align-center">
        <el-input v-model="ruleForm.code" placeholder="请输入验证码"></el-input>
        <img src="../images/codeImg.png" alt="">
      </div>
    </el-form-item>
    <el-form-item>
      <div class="flex align-center justify-between">
        <el-checkbox label="记住密码" name="type"></el-checkbox>
        <el-button type="text">忘记密码</el-button>
      </div>
    </el-form-item>
    <el-form-item>
      <el-button style="width: 100%;" type="primary" @click="submitForm('ruleForm')">登　　录</el-button>
    </el-form-item>
  </el-form>
</template>
<script>
export default {
  name: 'loginForm',
  data() {
    return {
      ruleForm: {
        username: '',
        password: '',
        code: ''
      },
      rules: {
        username: [
          { required: true, message: '请输入用户名', trigger: ['blur', 'change'] },
        ],
        password: [
          { required: true, message: '请输入密码', trigger: ['blur', 'change'] }
        ],
        code: [
            { required: true, message: '请输入验证码', trigger: ['blur', 'change'] }
        ]
      }
    }
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
        } else {
          return false;
        }
      });
    }
  }
}
</script>
<style lang="scss" scoped>
::v-deep .el-form-item__label{
    line-height: 40px !important;
    padding-bottom: 0 !important;
}
::v-deep .el-input__inner{
  height: 50px;
  line-height: 50px;
}
.codeBox{
  img{
    width: 153px;
    height: 50px;
    margin-left: 10px;
    border-radius: 4px;
    border: 1px solid #DCDFE6;
    box-sizing: border-box;
    cursor: pointer;
  }
}
</style>
